package de.jmda.gen.java.impl;

import java.util.LinkedList;
import java.util.List;

import de.jmda.gen.Generator;
import de.jmda.gen.java.ModifiersUtil;
import de.jmda.gen.java.TypeModifiersGenerator;

/**
 * TODO improve (constraints, ...)
 * @author roger.jmda@gmail.com
 */
public class DefaultTypeModifiersGenerator
		extends AbstractModifiersGenerator
		implements TypeModifiersGenerator
{
	public final static Generator PUBLIC    = dg(ModifiersUtil.PUBLIC);
	public final static Generator PROTECTED = dg(ModifiersUtil.PROTECTED);
	public final static Generator PRIVATE   = dg(ModifiersUtil.PRIVATE);
	public final static Generator FINAL     = dg(ModifiersUtil.FINAL);
	public final static Generator STATIC    = dg(ModifiersUtil.STATIC);
	
	private boolean bPublic    = false;
	private boolean bProtected = false;
	private boolean bPrivate   = false;
	private boolean bFinal     = false;
	private boolean bStatic    = false;
	
	@Override
	public List<Generator> getGeneratorComponents()
	{
		List<Generator> result = new LinkedList<Generator>();
		
		if (bPublic   ) { result.add(PUBLIC); }
		if (bProtected) { result.add(PROTECTED); }
		if (bPrivate  ) { result.add(PRIVATE); }
		if (bFinal    ) { result.add(FINAL); }
		if (bStatic   ) { result.add(STATIC); }
	
		return result;
	}
	
	public boolean isPublic()
	{
		return bPublic;
	}
	
	public void setPublic(boolean bPublic)
	{
		this.bPublic = bPublic;
	
		if (bPublic)
		{
			setPrivate(false);
			setProtected(false);
		}
	}
	
	public boolean isProtected()
	{
		return bProtected;
	}
	
	public void setProtected(boolean bProtected)
	{
		this.bProtected = bProtected;
	
		if (bProtected)
		{
			setPublic(false);
			setPrivate(false);
		}
	}
	
	public boolean isPrivate()
	{
		return bPrivate;
	}
	
	public void setPrivate(boolean bPrivate)
	{
		this.bPrivate = bPrivate;
	
		if (bPrivate)
		{
			setPublic(false);
			setProtected(false);
		}
	}
	
	public boolean isFinal()
	{
		return bFinal;
	}
	
	public void setFinal(boolean bFinal)
	{
		this.bFinal = bFinal;
	}
	
	public boolean isStatic()
	{
		return bStatic;
	}
	
	public void setStatic(boolean bStatic)
	{
		this.bStatic = bStatic;
	}
}